package cn.orange.ch07_binarytree;

import cn.orange.TreeNode;

/**
 * LC226.翻转二叉树
 */
public class LC226 {
    public TreeNode invertTree(TreeNode root) {
        if (root == null) {
            return null;
        }
        /*TreeNode t = root.left; //前序
        root.left = root.right;
        root.right = t;
        invertTree(root.left);
        invertTree(root.right);*/
        TreeNode left = invertTree(root.right); //后序
        TreeNode right = invertTree(root.left);
        root.left = left;
        root.right = right;
        return root;
    }
    public static void main(String[] args) {
        LC226 alg = new LC226();
        
    }
}
